<?php

/**
 * ResourcesController
 * 
 * @author
 * @version 
 */

require_once 'Rest/Controller/Action.php';

class Layered_ResourcesController extends Rest_Controller_Action
{
	
	
	public function viewAction ()
	{
		if (!$this->isValidAction()) {
			return;
		}
		
		$context = $this->getHelper('contextSwitch');
		$request = $this->getRequest();
		
		if ($context->getCurrentContext() != null) {
			// check to see if they have permissions, if not, turn context off
			// by removing the context param and re-initializing context.
			if (false) {
				$param = $context->getContextParam();
				$request->setParam($param, null);
				unset($_GET[$param]);
				unset($_POST[$param]);
				$context->initContext();
			}
		}
		
		$layered = LayeredContent::getInstance();
		
		if ($layered->hasCache()) {
			if ($layered->isCachedByBrowser()) {
				die();
			} else {
				die($layered->getCache());
			}
		}
		
		$data = $layered->getData();
		
		if (!$data) {
			$url = $layered->getHandler('urlHandler')->getUrl();
			throw new Zend_Controller_Action_Exception("Resource '$url' not found", 404);
		}
		
		
	}
	
	
	
}

